package cc.bookcloud.tool.ocr.common.parsetext;

import com.alibaba.fastjson.JSONArray;
import lombok.Data;

/**
 * @Desc: 全电电子发票(普通发票) --特征类型
 * @Version: 2.0
 * @Author: John Goo
 * @Date: 2024/12/02 14:26
 **/
@Data
public class InvoiceFeatureNormalElectronic extends InvoiceFeatureAbstract{


    private String title = "电子发票&&普通发票";


    public InvoiceFeatureNormalElectronic(String type, String typeDesc) {
        super(type, typeDesc);
    }




    public boolean title(Integer pos, String text, JSONArray array){
        boolean flag = false;

        // 发票头识别，考虑解析印章的干扰
        if (text.contains("电子发票(普通发票)") ){
            totalScore = totalScore + 100;
            flag = true;
        }else if(text.contains("普通发票") && (pos <=5 )){
            // 最上一位，综合识别
           // JSONObject preRow = array.getJSONObject(pos - 1);
           int newPost = (pos-1)<0 ? 0 : pos-1;
           String preText = array.getJSONArray(newPost).getJSONArray(1).getString(0);
           //String preText = preRow.getString("text");
           String combineStr = preText + text;
            // 级联判断
           if(combineStr.contains("电子发") || combineStr.contains("电子")){
               totalScore = totalScore + 100;
               flag = true;
           }

        }
        return flag;
    }





}
